package org.dentalcard.ui.i18n;

import java.io.FileInputStream;
import java.util.Locale;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;

/**
 * @user: Vladimir Chernishov
 * @date: 25.02.12
 * @time: 15:39
 */
public class I18nManager {

    private final ResourceBundle messages;
    private final Locale locale;

    private static I18nManager instance = new I18nManager(Locale.getDefault());

    private static I18nManager getInstance(){
        return instance;
    }

    private I18nManager(Locale locale) {
        this.locale = locale;
        this.messages = ResourceBundle.getBundle("Resources", locale);
    }
    
    private String getResource(String key){
        return  messages.getString(key);
    }
    
    public static String getRes(String key){
        return getInstance().getResource(key);
    }

    public static String getRes(String key, Object ... params){
        return String.format(getInstance().getResource(key), params);
    }

}
